/*
 * Copyright (c) United Binary LLC.  All rights reserved.
 * 
 * This code is licensed under the MIT License
 * 
 * SEE: http://harnessit.codeplex.com/license
 * 
 */
using System;
using UnitedBinary.UnitTests.Framework;

namespace UnitedBinary.HarnessIt.UnitTests.SharedTypes
{
	[Serializable]
	[TestExecutionMode(TestExecutionModes.Reuse)]
	public class TestClassWithSetupTeardown
	{
		private int counter = 0;

		public TestClassWithSetupTeardown()
		{
		}

		[TestOrder(TestOrderModes.First,1)]
		[TestMethod("This method will setup the member variables for subsequent tests.")]
		public void Setup(TestMethodRecord tmr)
		{
			// TODO: Run setup code here.  Use the tmr.RunTests and tmr.WriteLine
			// methods to report details if you want.

			counter++;
			tmr.RunTest(counter == 1, "Counter is 1.");
		}

		[TestOrder(TestOrderModes.Last,1)]
		[TestMethod("This method will free resources using by the tests.")]
		public void Teardown(TestMethodRecord tmr)
		{
			// TODO: Run cleanup code here.  Use the tmr.RunTests and tmr.WriteLine
			// methods to report details if you want.

			counter++;
			tmr.RunTest(counter == 3, "Counter is 3.");
		}

		[TestMethod("This is a regular test method which depends on setup having been executed.")]
		public void RegularTestMethod(TestMethodRecord tmr)
		{
			// TODO: Run test code assuming Setup has run.

			counter++;
			tmr.RunTest(counter == 2, "Counter is 2.");
		}
	}
}